package cn.edu.sjtu.dfa;

public class CJump extends Instruction {
	private Register v1;
	private Register v2;
	private String relOP;
	
	private Label l1;
	private Label l2;//actually the second label is just the next instruction in the list
	
	public CJump(Register v1, Register v2, String relOP, Label l1, Label l2) {
		this.v1 = v1;
		this.v2 = v2;
		this.relOP = relOP;
		this.l1 = l1;
		this.l2 = l2;
	}
	
	public Register getRegister1() {
		return v1;
	}
	
	public Register getRegister2() {
		return v2;
	}
	
	public String getRelOP() {
		return relOP;
	}
	
	public Label getLabel1() {
		return l1;
	}
	
	public Label getLabel2() {
		return l2;
	}

	public void setLabel1(Label l1){
		this.l1 = l1;
	}
	public void setLabel2(Label l2){
		this.l2 = l2;
	}
	@Override
	public String toString() {
		String ret = "Cjump: " + relOP + " v" + v1.getRegister();
		if (v2 != null) {
			ret = ret + " v" + v2.getRegister();
		}
		ret = ret + " " + l1.toString() + " else " + l2.toString();
		return  ret;
	}
}
